using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ghasam.Business.Services;

public partial class ChequeList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckCustomerType();
    }
    private IPaymentService paymentService;
    public IPaymentService PaymentService
    {
        get { return paymentService; }
        set { paymentService = value; }
    }
    private int _isFormal;
    public int isFormal
    { get { if (_isFormal != null) return _isFormal; } }
    static int numberDiv = 0;
    private void CheckCustomerType() {
        bool show = CommonHelper.ShowHiddenCustomers();
        divHiddenCustomers.Visible = show;
    }

    protected void checkFormalCustomer()
    {
        bool show = CommonHelper.ShowHiddenCustomers();
            _isFormal = 1;

        if (show && rbHiddenCustomers.Checked) {
            _isFormal = 0;
        }
        else if (show && rbAll.Checked) {
            _isFormal = -1;
        }
    }

    private void bindGrid(int pageNumber)
    {
        gvCheques.DataSource = PaymentService.FindAllPaymentByParam(Convert.ToBoolean(_isFormal), 15, pageNumber);
        gvCheques.DataBind();
    }
    protected void CustomerTypeCheckedChanged(object sender, EventArgs e)
    {
        bindGrid(0);
    }

    protected void gvCheques_RowDeleted( object sender, GridViewDeletedEventArgs e ) {
        gvCheques.SelectedIndex = -1;
        gvCheques.DataBind();
    }
    protected void gvCheques_Sorting(object sender, GridViewSortEventArgs e)
    {
        bool dir;
        if ((numberDiv % 2) == 0)
            dir = true;
        else
            dir = false;
        numberDiv++;
        gvCheques.DataSource = PaymentService.SortPaymentCheque(e.SortExpression, dir);
        gvCheques.DataBind();
    }
}
